package com.aliwo.controller.admin;

import com.aliwo.domain.Video;
import com.aliwo.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 管理员用户权限.
 *
 * @author xuyayuan
 * @date 2021/10/17 13:24
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("admin/api/v1/videos")
public class AdminVideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping("save")
    public ResponseEntity<Integer> save(@RequestBody Video video) {
        Integer rows = videoService.save(video);
        System.out.println("id:" + video.getId());
        return ResponseEntity.ok(rows);
    }

    @PutMapping("update")
    public ResponseEntity<Boolean> update(@RequestBody Video video) {
        Boolean updateFlag = videoService.update(video);
        return ResponseEntity.ok(updateFlag);
    }

    @PutMapping("delete")
    public ResponseEntity<Boolean> delete(@RequestParam("id") Integer id) {
        Boolean deleteFlag = videoService.delete(id);
        return ResponseEntity.ok(deleteFlag);
    }
}
